package com.zshstart.gmalllogger.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zshstart
 * @create 2021-09-18 11:58
 */
@RestController
@Slf4j
public class LoggerController {
    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    @RequestMapping("/test")
    public String test1() {
        System.out.println("aaaa");
        return "success";
    }

    @RequestMapping("/applog")
    public String getLogger(@RequestParam("param") String jsonStr) {
        //1.打印
        System.out.println(jsonStr);

        //2.落盘
        log.info(jsonStr);

        //3.写入kafka
        kafkaTemplate.send("ods_base_log", jsonStr);

        return "success";
    }
}
